package slap.mvc.router;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import slap.http.Request;
import slap.mvc.Action;

public class DirectRouter implements Router {
	
	public Map<String, Action> routes = new ConcurrentHashMap<String, Action>();

	@Override
	public void add(Action action) {
		assert action.direct() != null;
		routes.put(action.direct(), action);
	}

	@Override
	public Action route(Request request) {
		return routes.get(request.path());
	}

	@Override
	public boolean contains(Action action) {
		return routes.containsKey(action.direct());
	}
	
	
}
